<?php
namespace globalunit\utils;


use globalunit\logic\TaskCallback;
use QYS\Log\Log;

Class TaskHelper{

    private static $server = null;

    public static function task($roomid, $c, $m, $data, $callback = null)
    {
        if(self::$server === null) {
            self::$server = GlobalUnit::$server;
        }
        $cmd=array(
            "c"=>$c,
            "m"=>$m,
            "roomid"=>$roomid,
            "tp"=>'task',
            "data"=>$data,
        );
        self::$server->task($cmd, -1, $callback);
    }

    public static function taskwait($roomid, $c, $m, $data, $timeout = 3, $dstWorkerId = -1)
    {
        if(self::$server === null) {
            self::$server = GlobalUnit::$server;
        }
        $cmd=array(
            "c"=>$c,
            "m"=>$m,
            "roomid"=>$roomid,
            "tp"=>'task',
            "data"=>$data,
        );
        return self::$server->taskwait($cmd, $timeout, $dstWorkerId);
    }

}
